home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Development Platforms / Apple II / Apple II Sample Code / MPW IIGS SC / SC.024.Teach / teach.p / uEvent.inc.p < prev    next >
Encoding:
Text File  |  1990-06-24  |  3.2 KB  |  138 lines  |  [TEXT/MPS ]

  1. {**********************************************************************
  2. {*
  3. {* Teach uEvent -- Version 3.0  (implemenation)
  4. {*
  5. {* Copyright (c)
  6. {* Apple Computer, Inc.  1986-1990
  7. {* All Rights Reserved.
  8. {*
  9. {* Developer Technical Support Apple II Sample Code
  10. {*
  11. {* This file contains the code which implements the 
  12. {* main event loop used by the Teach program.
  13. {*
  14. {**********************************************************************}
  15. {$R-}
  16.  
  17.  
  18. PROCEDURE Debug;  INLINE $0000;
  19.  
  20. {*******************************************************************}
  21. {
  22. { CheckFrontW
  23. {
  24. { This routine checks the front window to see if any changes need
  25. { to be made to the menu items.
  26. {
  27. { We do this so that the edit items are only active when a desk
  28. { accessory is active.
  29. {
  30. {*******************************************************************}
  31. procedure CheckFrontW;
  32.  
  33. var 
  34.     theWindow    : GrafPortPtr;
  35.  
  36.     procedure   EnableDAItems;
  37.         begin
  38.             EnableMItem(UndoItem);
  39.             EnableMItem(CloseItem);
  40.             SetMenuFlag ($FF7F,EditMenuID);   { enable the edit menu }
  41.         end;
  42.     procedure   EnableAppItems;
  43.         begin
  44.             EnableMItem(SelectAllItem);
  45.             EnableMItem(CloseItem);
  46.             EnableMItem(SaveItem);
  47.             EnableMItem(SaveAsItem);
  48.             EnableMItem(PageSetupItem);
  49.             EnableMItem(PrintItem);
  50.             SetMenuFlag ($FF7F,SizeMenuID);   { enable the size menu }
  51.             SetMenuFlag ($FF7F,StyleMenuID);   { enable the style menu }
  52.             SetMenuFlag ($FF7F,FontMenuID);   { enable the font menu }
  53.             SetMenuFlag ($FF7F,EditMenuID);   { enable the edit menu }
  54.         end;
  55.     procedure   DisableDAItems;
  56.         begin
  57.             DisableMItem(UndoItem);
  58.         end;
  59.     procedure    DisableAppItems;
  60.         begin
  61.             SetMenuFlag ($0080,FontMenuID);   { disable the font menu }
  62.             SetMenuFlag ($0080,StyleMenuID);   { disable the style menu }
  63.             SetMenuFlag ($0080,SizeMenuID);   { disable the size menu }
  64.             DisableMItem(SaveItem);
  65.             DisableMItem(SaveAsItem);
  66.             DisableMItem(PageSetupItem);
  67.             DisableMItem(PrintItem);
  68.             DisableMItem(SelectAllItem);
  69.         end;
  70.  
  71. begin   {of CheckFrontW}
  72.     { Get the front window into local storage.}
  73.     theWindow := FrontWindow;
  74.     
  75.     { If the LastWindow is this window, we are all set. }
  76.     if theWindow = lastWindow then Exit(CheckFrontW);
  77.     
  78.     { If there are no windows, everything should be disabled }
  79.     if theWindow = nil then 
  80.         begin
  81.             disableDAItems;
  82.             disableAppItems;
  83.             DisableMItem(CloseItem);
  84.         end 
  85.     else
  86.         begin
  87.             
  88.             { Now look at what kind of window we have...}
  89.             if GetSysWFlag (theWindow) then 
  90.                 begin   {Set up for da windows}
  91.                     disableAppItems;
  92.                     enableDAItems;
  93.                 end
  94.                else
  95.                 begin   {Set up for our windows}
  96.                     disableDAItems;
  97.                     enableAppItems;
  98.                 end;
  99.         end;
  100.     
  101.     { Remember this for next time. }
  102.     DrawMenuBar;
  103.     lastWindow := theWindow;
  104. end;    {of CheckFrontW}
  105.  
  106.  
  107.  
  108.  
  109.  
  110. {************************************************************************
  111. {
  112. { MainEvent
  113. {
  114. { This is the main part of the program.  The program cycles in this
  115. { loop until the user choose select.
  116. {
  117. {************************************************************************}
  118. procedure mainEvent;
  119.  
  120.  
  121. var 
  122.        code : integer;
  123.  
  124.  
  125. begin   {of MainEvent}
  126.  
  127.    repeat
  128.        checkFrontW;
  129.        code := TaskMaster ($FFFF,event);
  130.        case code of
  131.            wInGoAway    : doCloseTop;
  132.            wInSpecial,
  133.            wInMenuBar    : doMenu;
  134.        end;
  135.    until quitFlag;
  136. end;    {of MainEvent}
  137.  
  138.